﻿using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Tools
{
    class Program
    {
        static void Main(string[] args)
        {
            //var src = "src.txt";

            //var terminals = 3;

            //var content = File.ReadAllText(src);

            //content = content.Replace("\r\n", ",").Replace("\n", ",");

            //var lines = content.Split(",").Where(s => !string.IsNullOrEmpty(s));

            //var total = lines.Count();

            //var average = total % terminals == 0 ? total / terminals : total / terminals + 1;

            //var dst = $"{DateTime.Now:yyyy-MM-dd_HH_mm_ss}.txt";

            //var newLine = Encoding.UTF8.GetBytes(Environment.NewLine);

            //using (var fs = File.Open(dst, FileMode.OpenOrCreate, FileAccess.Write))
            //{
            //    for (var i = 0; i < terminals; i++)
            //    {
            //        var averageLines = lines.Skip(i * average).Take(average);
            //        var strContent = string.Join(",", averageLines);
            //        var bytes = Encoding.UTF8.GetBytes(strContent);

            //        fs.Write(bytes, 0, bytes.Count());
            //        fs.Write(newLine, 0, newLine.Length);
            //    }
            //}

            if (Comparator.Compare("imagescomparator.exe", "1.png", "2.png", out var degree))
                Console.WriteLine($"图片相似度为:{degree * 100}%");
            else
                Console.WriteLine("图片相似度对比失败");

            Console.ReadKey();
        }
    }
}
